<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <style>
        * {
            margin: 0px;
            padding: 0px;
        }

        img {
            /* 上边距 */
            margin-top: 35px;
            width: 200px;
            cursor: pointer;

        }

        body {
            background-image: url("img/1.jpg");
        }

        div {
            /* div内容居中 */
            text-align: center;
            height: 200px;
            /* 背景色 */
            background-color: rgba(255, 255, 255, 0.3);
        }
    </style>
</head>

<body>
    <div id="dv">
        <img src="img/1.jpg" alt="">
        <img src="img/2.jpg" alt="">
        <img src="img/3.jpg" alt="">
    </div>
    <script>
        function my$(id) {
            return document.getElementById(id);
        }
        var divObjet = my$("dv");
        //获取子元素    
        var divSubElements = divObjet.children;

        //注册点击事件
        for (const divSubElement of divSubElements) {
            //聚焦
            divSubElement.onclick = function () {
                document.body.style.backgroundImage = "url(" + this.src + ")";
            }

        }
        


    </script>
</body>

</html>